01-Makefile.patch, changes:
* on x86_64 systems, install libraries in /usr/lib64
* added shared library target
* added CFLAGS_EXTRA to pass $SLKCFLAGS (can be improved)
* avoid building examples
* disabled debug information

--- quickjs-2021-03-27/Makefile	2021-03-27 07:00:32.000000000 -0300
+++ quickjs-2021-03-27-modified/Makefile	2022-08-02 21:52:01.476250120 -0300
@@ -36,12 +36,14 @@
 
 ifdef CONFIG_DARWIN
 # use clang instead of gcc
-CONFIG_CLANG=y
+#CONFIG_CLANG=y
 CONFIG_DEFAULT_AR=y
 endif
 
 # installation directory
 prefix=/usr/local
+libdir=$(prefix)/lib
+CFLAGS_EXTRA=
 
 # use the gprof profiler
 #CONFIG_PROFILE=y
@@ -66,7 +68,7 @@
 ifdef CONFIG_CLANG
   HOST_CC=clang
   CC=$(CROSS_PREFIX)clang
-  CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
+  CFLAGS= -Wall -MMD -MF $(OBJDIR)/$(@F).d
   CFLAGS += -Wextra
   CFLAGS += -Wno-sign-compare
   CFLAGS += -Wno-missing-field-initializers
@@ -87,7 +89,7 @@
 else
   HOST_CC=gcc
   CC=$(CROSS_PREFIX)gcc
-  CFLAGS=-g -Wall -MMD -MF $(OBJDIR)/$(@F).d
+  CFLAGS= -Wall -MMD -MF $(OBJDIR)/$(@F).d
   CFLAGS += -Wno-array-bounds -Wno-format-truncation
   ifdef CONFIG_LTO
     AR=$(CROSS_PREFIX)gcc-ar
@@ -107,12 +109,15 @@
 DEFINES+=-D__USE_MINGW_ANSI_STDIO # for standard snprintf behavior
 endif
 
+DEFINES += -DCONFIG_LIBDIR=\"$(libdir)\"
+
+CFLAGS+=$(CFLAGS_EXTRA)
 CFLAGS+=$(DEFINES)
 CFLAGS_DEBUG=$(CFLAGS) -O0
 CFLAGS_SMALL=$(CFLAGS) -Os
 CFLAGS_OPT=$(CFLAGS) -O2
 CFLAGS_NOLTO:=$(CFLAGS_OPT)
-LDFLAGS=-g
+#LDFLAGS=-g
 ifdef CONFIG_LTO
 CFLAGS_SMALL+=-flto
 CFLAGS_OPT+=-flto
@@ -157,14 +162,14 @@
 ifdef CONFIG_ASAN
 PROGS+=
 else
-PROGS+=examples/hello examples/hello_module examples/test_fib
+#PROGS+=examples/hello examples/hello_module examples/test_fib
 ifndef CONFIG_DARWIN
-PROGS+=examples/fib.so examples/point.so
+#PROGS+=examples/fib.so examples/point.so
 endif
 endif
 endif
 
-all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS)
+all: $(OBJDIR) $(OBJDIR)/quickjs.check.o $(OBJDIR)/qjs.check.o $(PROGS) libquickjs.so
 
 QJS_LIB_OBJS=$(OBJDIR)/quickjs.o $(OBJDIR)/libregexp.o $(OBJDIR)/libunicode.o $(OBJDIR)/cutils.o $(OBJDIR)/quickjs-libc.o
 
@@ -187,6 +192,9 @@
 qjs$(EXE): $(QJS_OBJS)
 	$(CC) $(LDFLAGS) $(LDEXPORT) -o $@ $^ $(LIBS)
 
+libquickjs.so: $(QJS_LIB_OBJS)
+	$(CC) -shared $(LDFLAGS) -fPIC $(LDEXPORT) -o $@ $^ $(LIBS)
+
 qjs-debug$(EXE): $(patsubst %.o, %.debug.o, $(QJS_OBJS))
 	$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
 
@@ -299,13 +307,15 @@
 
 install: all
 	mkdir -p "$(DESTDIR)$(prefix)/bin"
-	$(STRIP) qjs qjsc
+	$(STRIP) qjs qjsc libquickjs.so
 	install -m755 qjs qjsc "$(DESTDIR)$(prefix)/bin"
 	ln -sf qjs "$(DESTDIR)$(prefix)/bin/qjscalc"
-	mkdir -p "$(DESTDIR)$(prefix)/lib/quickjs"
-	install -m644 libquickjs.a "$(DESTDIR)$(prefix)/lib/quickjs"
+	mkdir -p "$(DESTDIR)/$(libdir)/quickjs"
+	install -m644 libquickjs.a "$(DESTDIR)/$(libdir)/quickjs"
+	install -m644 libquickjs.so "$(DESTDIR)/$(libdir)/quickjs"
+	ln -s quickjs/libquickjs.so "$(DESTDIR)/$(libdir)/libquickjs.so"
 ifdef CONFIG_LTO
-	install -m644 libquickjs.lto.a "$(DESTDIR)$(prefix)/lib/quickjs"
+	install -m644 libquickjs.lto.a "$(DESTDIR)/$(libdir)/quickjs"
 endif
 	mkdir -p "$(DESTDIR)$(prefix)/include/quickjs"
 	install -m644 quickjs.h quickjs-libc.h "$(DESTDIR)$(prefix)/include/quickjs"
